@extends('layouts.app')
@include('shop.sidebar')
@section('content')
    <div class="content">
        <div class="row custom-invoice">

            @can('shop_store_recommend_add')
                <a class="btn btn-success" href="{{ route("admin.shop.recommend.create", ['id' => $shop->id]) }}">添加</a>
            @endcan

            <br />
            <br />
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>名称</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($data as $item)
                    @php
                        $tmp = $goods->get($item->link_id);
                    @endphp
                    <tr>
                        <td>{{ $tmp->name }}</td>
                        <td>{{ \App\Modules\Good\Models\Good::$showStatus[$tmp->status]  }}</td>
                        <td>
                            @can('shop_store_recommend_del')
                                <a class="btn btn-danger btn-xs delete-confirm" data-href="{{ route('admin.shop.recommend.delete', ['id' => $item->id]) }}"><i class="fa fa-trash-o"></i> 删除</a>
                            @endcan
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
    </div>
@endsection
@push('scripts')
    <script>
        $('.change-sort').on('change', function () {
            var sort = $(this).val();
            var id = $(this).attr('data-id');
            $.ajax({
                url: '{{ route('admin.shop.sort') }}',
                type: "GET",
                dataType:'json',
                data: {
                    id: id,
                    sort: sort,
                },
                success: function (re) {
                }
            });
        });

    </script>
@endpush
